package com.example.administrator.orchardeveryday.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.example.administrator.orchardeveryday.BaseApp;
import com.example.administrator.orchardeveryday.config.UrlConstants;

/**
 * Created by Administrator on 15-10-25.
 */
public class UserSqliteOpenHelper extends SQLiteOpenHelper{

    public UserSqliteOpenHelper() {
        super(BaseApp.getInstance(), UrlConstants.DB_NAME, null, UrlConstants.DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        String sqlGoods= DbBean.GoodsDb.CREATE_GOODS_TAB;
        db.execSQL(sqlGoods);
        String sqlUser= DbBean.UserDb.CREATE_USER_TAB;
        db.execSQL(sqlUser);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        if(newVersion>oldVersion)
        {
            db.execSQL(DbBean.UserDb.DROP_TAB);
            onCreate(db);
        }
    }
}
